//
//  HWRecommendedViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2020/9/23.
//  Copyright © 2020 Chendaobin. All rights reserved.
// 推荐


#import "HWRecommendedViewController.h"
#import "SDCycleScrollViewCdb.h"
#import "HWOpenClothingViewController.h"

#import "HWLiBaoCenterViewController.h" // 礼包中心

#import "HWPaiHangBangViewController.h" // 排行榜



#import "HWmouxingModel.h"
#import "HWHomezhongyaodeCell.h"
#import "HWbiaoqiankongzhiViewController.h" //标签控制器
#import "HWGiftBagCenterzhongxingViewController.h" // 最新礼包中心界面
#import "HWDailyCheckController.h"  // 每日签到
#import "HWTYouXiKaiFuViewController.h" // 新的游戏开服






@interface HWRecommendedViewController ()<UITableViewDelegate,UITableViewDataSource,SDCycleScrollViewCdbDelegate>

@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic) SDCycleScrollViewCdb *cycleScrollView;
@property(strong,nonatomic) NSArray *dataArr;
@property(strong,nonatomic) UIView *headtableView;
@property(strong,nonatomic) NSArray *slidArr;
@property(strong,nonatomic) UIView *kaifukapianView;


// 重磅推荐
@property(strong,nonatomic) UIView *zhongbangView;
@property(strong,nonatomic) UIImageView *tuijiaIcoiamge;



@property(strong,nonatomic) UIView *cardView; //卡片UIView
@property(strong,nonatomic) UIImageView *icoiamgeView; // ico图标
@property(strong,nonatomic) UILabel *mingchengLabel; // 名称

@property(strong,nonatomic) UIButton *starsBut; // 星星
@property(strong,nonatomic) UIButton *xiangqingBtn; // 详情
@property(strong,nonatomic) UILabel *leixingbiaoqianLabel;
@property(strong,nonatomic) NSDictionary *tuijianDic;
@property(strong,nonatomic) NSMutableArray *gameArr;

@property(strong,nonatomic) NSMutableArray *onefeilMuArr;
@property(strong,nonatomic) NSMutableArray *twoFeilMuArr;

@property(strong,nonatomic) UIView *footsehzhview;
@property(strong,nonatomic) UIView * baisede1View;
 










@end

@implementation HWRecommendedViewController


- (SDCycleScrollViewCdb *)cycleScrollView {
    if (!_cycleScrollView) {
        // 网络加载 --- 创建不带标题的图片轮播器
        _cycleScrollView = [SDCycleScrollViewCdb cycleScrollViewWithFrame:CGRectMake(10, 5, kScreenW-2*10, 200) imageURLStringsGroup:nil];
        
        _cycleScrollView.infiniteLoop = YES;
        _cycleScrollView.delegate = self;
        _cycleScrollView.placeholderImage=[UIImage imageNamed:@"banner"];
        _cycleScrollView.pageControlStyle = SDCycleScrollViewCdbPageContolStyleNone;
        _cycleScrollView.autoScrollTimeInterval = 2.0; // 轮播时间间隔，默认1.0秒，可自定义
        _cycleScrollView.backgroundColor = [UIColor clearColor];
        
        
    }
    return _cycleScrollView;
}



-(UITableView *)mainaTableVie {
    
    if (_mainaTableVie == nil
        ) {
        
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-CF_NavHeight-44-CF_TabbarHeight) style:UITableViewStyleGrouped];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        _mainaTableVie.backgroundColor = RGB(247, 247, 247);


        
    }
    return   _mainaTableVie ;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
     self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupUI];
    
    [self addheadtableView];
    
    
    [self addrefreshControl];
    

    
}


- (void)setupUI {
    
    
    self.gameArr = [[NSMutableArray alloc]init];
    
    [self.view addSubview:self.mainaTableVie];
    
    
}


//  添加
- (void)addheadtableView {
    
    
    self.headtableView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 5+200+80+88)];
    self.headtableView.backgroundColor = [UIColor redColor];
    self.headtableView.backgroundColor = RGB(247, 247, 247);
    self.mainaTableVie.tableHeaderView = self.headtableView;
    
    [self addheadView];

    [self zhongbangtuijianUIView];
    
    [self addfootView];
    
    

}



//设置tableview
- (void)addfootView {
    
    self.footsehzhview  = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 118+34)];
    self.footsehzhview.backgroundColor = RGB(247, 247, 247);
    self.mainaTableVie.tableFooterView =  self.footsehzhview ;
    
    
    self.baisede1View = [[UIView alloc]initWithFrame:CGRectMake(10, 10, kScreenW-20, 108)];
    self.baisede1View.layer.cornerRadius = 10;
    self.baisede1View.layer.masksToBounds = YES;
    self.baisede1View.backgroundColor = [UIColor whiteColor];
    [self.footsehzhview addSubview:self.baisede1View];
    
    
        UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW-80)/2,   self.baisede1View.bottom, 80, 34)];
       textlabel.text = @"我也是有底线的";
       textlabel.textAlignment =  NSTextAlignmentCenter;
       textlabel.textColor = RGB(204, 204, 204);
       textlabel.font = [UIFont systemFontOfSize:10];
      textlabel.backgroundColor = [UIColor clearColor];
       [self.footsehzhview  addSubview:textlabel];
    
    
    UIView *fenxiang = [[UIView alloc]initWithFrame:CGRectMake((kScreenW-80)/2-50-5, self.baisede1View.bottom+16, 50, 1)];
    fenxiang.backgroundColor = RGB(238, 238, 238);
    [self.footsehzhview addSubview:fenxiang];
    
    UIView *fenxiang1 = [[UIView alloc]initWithFrame:CGRectMake((kScreenW-80)/2+5+80, self.baisede1View.bottom+16, 50, 1)];
    fenxiang1.backgroundColor = RGB(238, 238, 238);
    [self.footsehzhview addSubview:fenxiang1];
    
    
     UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(12, 24-10,4,16)];
           
           view1.backgroundColor = RGB(248, 119, 6);
       //    view1.layer.cornerRadius = 10;
       //    view1.layer.masksToBounds = YES;
       //
           [self.baisede1View addSubview:view1];
           
       
       
       UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(view1.right+6,20-10, 200, 26)];
                  //     nameLabel.text = fanlilistArr[i];
           //  nameLabel.backgroundColor =  RGB(248, 119, 6);
            nameLabel.backgroundColor = [UIColor clearColor];
             nameLabel.textAlignment = NSTextAlignmentLeft;
             nameLabel.font = [UIFont systemFontOfSize:18];
             nameLabel.textColor = RGB(68, 68, 68);
       
    
    //    nameLabel.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:20];//又粗又斜
        //     nameLabel.layer.cornerRadius = 8;
        //     nameLabel.layer.masksToBounds = YES;
       UIFontDescriptor * fontD = [nameLabel.font.fontDescriptor
       fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold
                       | UIFontDescriptorTraitItalic];
         nameLabel.font = [UIFont fontWithDescriptor:fontD size:0];

             nameLabel.text = @"其他热门分类";
          nameLabel.text = [HWjianzhiduiObject keylocalization:@"其他热门分类"];
    
          [self.baisede1View addSubview:nameLabel];
    

    
    
    
    
    
    
}


// 重磅推荐

- (void)zhongbangtuijianUIView {
    
    
    
    
    
    self.zhongbangView = [[UIView alloc] initWithFrame:CGRectMake(10,self.kaifukapianView.bottom, kScreenW-20, 88)];
    self.zhongbangView.backgroundColor = RGB(255, 255, 255);
    self.zhongbangView.layer.cornerRadius = 10;
    self.zhongbangView.layer.masksToBounds = YES;
    [self.headtableView addSubview: self.zhongbangView];
    
    
    UITapGestureRecognizer *zhongbangViewtap  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(zhongbangtapGes)];
    [self.zhongbangView addGestureRecognizer:zhongbangViewtap];
    
    
    
    self.tuijiaIcoiamge = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 61, 58)];
    self.tuijiaIcoiamge.image = [UIImage imageNamed:@"zhongbangtuijain_ico"];
    
    [self.zhongbangView addSubview:self.tuijiaIcoiamge];
    
    
    
    
    
    
    self.cardView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 88)];
    self.cardView.backgroundColor = [UIColor whiteColor];
//    self.cardView.layer.cornerRadius = 10;
//    self.cardView.layer.masksToBounds = YES;
  
    self.cardView.frame = CGRectMake(72, 0, kScreenW-72-20, 88);
    
    
    [self.zhongbangView addSubview:self.cardView];
    
    
    
    [self diyigekaipianView];
    
    
    
}


// 第一个卡片UIview
- (void)diyigekaipianView {
    
    
    self.icoiamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 18, 52, 52)];
    self.icoiamgeView.backgroundColor = [UIColor yellowColor];
    self.icoiamgeView.layer.cornerRadius = 10;
    self.icoiamgeView.layer.masksToBounds = YES;
    [self.cardView addSubview:self.icoiamgeView];
    
    
    // 传奇
  
    
    
    
     UILabel *netLabel = [[UILabel alloc]initWithFrame:CGRectMake( self.icoiamgeView.right+10, 14, kScreenW-100, 20)];
     netLabel.textColor  = RGB(68, 68, 68);
     netLabel.text = @"游戏名称";
     netLabel.font = [UIFont systemFontOfSize:14];
    self.mingchengLabel = netLabel;
     [self.cardView addSubview:netLabel];
    
    
    
    
    self.starsBut = [UIButton  createNormalButtonWithFrame:CGRectMake(self.icoiamgeView.right+10, self.mingchengLabel.bottom+1, 15+8+3, 14) Image:@"stars_ico" Title:@"8.0" font:10 imageSize:CGSizeMake(8, 8)];
    [self.starsBut layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:3];
    self.starsBut.backgroundColor = [UIColor clearColor];
    [self.cardView addSubview: self.starsBut];
    
  
    
    
       UILabel *leixingLabe = [[UILabel alloc]initWithFrame:CGRectMake( self.starsBut.right+5, self.mingchengLabel.bottom+2, 210, 14)];
     leixingLabe.textColor  = RGB(170, 170, 170);
     leixingLabe.text = @"玄幻";
     leixingLabe.font = [UIFont systemFontOfSize:10];
     self.leixingbiaoqianLabel = leixingLabe;
     leixingLabe.backgroundColor = [UIColor clearColor];
     [self.cardView addSubview:leixingLabe];
    
    
    
    
    NSString *xiangqing =  [HWjianzhiduiObject keylocalization:@"详情"];

    self.xiangqingBtn  = [UIButton setButtonWithFrame:CGRectMake(self.cardView.width-17-44, (88-44)/2, 44, 30) Title:xiangqing Image:nil Font:12 Color:RGB(248, 119, 6) Target:self Selector:@selector(xianqingBut)];
  //   self.xiangqingBtn.backgroundColor = [UIColor  bm_colorGradientChangeWithSizeView: self.xiangqingBtn];
    self.xiangqingBtn.layer.cornerRadius = 15;
    self.xiangqingBtn.layer.masksToBounds = YES;
    self.xiangqingBtn.layer.borderWidth = 1;
    self.xiangqingBtn.layer.borderColor = RGB(248, 119, 6).CGColor;
    [self.cardView addSubview:self.xiangqingBtn];
    

    
    for (int i = 0; i < 3; i++) {
        
        
       UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake(self.icoiamgeView.right+10+i*50+i*5, self.starsBut.bottom+5, 50, 14)];
       textlabel.text = @"礼包";
       textlabel.textAlignment =  NSTextAlignmentCenter;
       textlabel.textColor = [UIColor whiteColor];
       textlabel.font = [UIFont systemFontOfSize:10];
       textlabel.tag = i+100;
       textlabel.backgroundColor = [UIColor redColor];
       textlabel.layer.cornerRadius = 2;
       textlabel.layer.masksToBounds = YES;
       [self.cardView addSubview:textlabel];
       textlabel.hidden = NO;
        
    }
    
    
    
  
    
    
    
    
}





// 点击详情buton
- (void)xianqingBut {
    
    
    
    
}



// 添加headeView
- (void)addheadView  {
    
    
    
    self.cycleScrollView.localizationImageNamesGroup = @[[UIImage imageNamed:@"banner"],[UIImage imageNamed:@"banner"],[UIImage imageNamed:@"banner"]];
     //轮播图
     //  self.cycleScrollView.imageURLStringsGroup = imagesURLStrings;
     //轮播图
     [self.headtableView addSubview:_cycleScrollView];
    
    
    self.kaifukapianView = [[UIView alloc]initWithFrame:CGRectMake(0,  self.cycleScrollView.bottom, kScreenW, 80)];
    self.kaifukapianView.backgroundColor = RGB(247, 247, 247);
    [self.headtableView addSubview:self.kaifukapianView];
    
    CGFloat daxiao =    (kScreenW-40)/3;
    
    
   //  NSArray *arr1 = @[@"游戏开服",@"礼包中心",@"新游速递"];
    
    NSArray *arr1 = @[[HWjianzhiduiObject keylocalization:@"游戏开服"],[HWjianzhiduiObject keylocalization:@"礼包中心"],[HWjianzhiduiObject keylocalization:@"新游速递"]];
    
   //   NSArray *arr2 = @[@"开服抢先知",@"边玩边领",@"新游抢先知"];
    
    NSArray *arr2 =  @[[HWjianzhiduiObject keylocalization:@"开服抢先知"],[HWjianzhiduiObject keylocalization:@"边玩边领"],[HWjianzhiduiObject keylocalization:@"新游抢先知"]];
    
    
    
   //  NSArray *arr3 = @[@"gameOpenClothing",@"libaozhongxing",@"xingyoukuaidi"];
    
    NSArray *arr3 = @[@"gameOpenClothing",@"libaozhongxing",@"xingyoukuaidi"];
    
    for (int i = 0; i < 3; i++) {
      
        UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(daxiao*i+i*10+10 , 10, daxiao, 60)];
        view1.backgroundColor = RGB(255, 255, 255);
        view1.layer.cornerRadius = 10;
        view1.layer.masksToBounds = YES;
        view1.tag = 100 +i;
        [self.kaifukapianView  addSubview:view1];
        
        
        

        UIImageView *iamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(daxiao-16-8, 8, 16, 16)];
        iamgeView.backgroundColor = [UIColor clearColor];
        iamgeView.image = [UIImage imageNamed:arr3[i]];
        [view1 addSubview:iamgeView];
        
         
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewtap:)];
        [view1 addGestureRecognizer:tap];
        
        
        
        UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10,10, daxiao-10, 22)];
                     //     nameLabel.text = fanlilistArr[i];
              //  nameLabel.backgroundColor =  RGB(248, 119, 6);
               nameLabel.backgroundColor = [UIColor clearColor];
                nameLabel.textAlignment = NSTextAlignmentLeft;
                nameLabel.font = [UIFont systemFontOfSize:14];
                nameLabel.textColor = RGB(68, 68, 68);
           //     nameLabel.layer.cornerRadius = 8;
        nameLabel.text =  arr1[i];
        [view1 addSubview:nameLabel];
        
        
        UILabel *nameLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(10,nameLabel.bottom+2, daxiao-10, 14)];
                           //     nameLabel.text = fanlilistArr[i];
                    //  nameLabel.backgroundColor =  RGB(248, 119, 6);
                     nameLabel1.backgroundColor = [UIColor clearColor];
                      nameLabel1.textAlignment = NSTextAlignmentLeft;
                      nameLabel1.font = [UIFont systemFontOfSize:10];
                      nameLabel1.textColor = RGB(170, 170, 170);
                 //     nameLabel.layer.cornerRadius = 8;
              nameLabel1.text =  arr2[i];
              [view1 addSubview:nameLabel1];
        
        
         
    }
  
    

    
    
}




- (void)viewtap:(UITapGestureRecognizer *)sender {
    
    UIView *view = sender.view;
    NSInteger tag = view.tag;
    
    
    if (tag == 100) {
        
//        HWOpenClothingViewController *open = [[HWOpenClothingViewController alloc]init];
//        [self.navigationController pushViewController:open animated:YES];
//
        
        
        HWTYouXiKaiFuViewController *youxikaifu = [[HWTYouXiKaiFuViewController alloc]init];
        [self.navigationController pushViewController:youxikaifu animated:YES];
        
        
         
    } else if (tag == 101) {
        
        
        
//        HWLiBaoCenterViewController *libao = [[HWLiBaoCenterViewController alloc]init];
//        [self.navigationController  pushViewController:libao animated:YES];
        
        
        HWGiftBagCenterzhongxingViewController *zuixing = [[HWGiftBagCenterzhongxingViewController alloc]init];
        [self.navigationController  pushViewController:zuixing animated:YES];
        
        
        

        
        
    } else if (tag == 102) {
        
        
        HWPaiHangBangViewController *paihang = [[HWPaiHangBangViewController alloc]init];
        
        [self.navigationController pushViewController:paihang animated:YES];
        
        
        
    }
    
    
   
    
    
}




- (void)addrefreshControl {
    
    self.mainaTableVie.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(underRefresh)];
    
    [self.mainaTableVie.mj_header beginRefreshing];
    
   //  self.mainaTableVie.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(onRefresh)];
}



#pragma  mark --------- 下拉刷新
- (void)underRefresh {
    
    //    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    //        // 结束刷新
    //        [self.mainaTableVie.mj_header endRefreshing];
    //    });
    
    
    // [SVProgressHUD show];
    

    __weak typeof(self) weakSelf = self;
    
// self.gameArr = [[NSMutableArray alloc]init];
//
//      //   self.reQiP  = @"1";
//
//    self.onefeilMuArr = [[NSMutableArray alloc]init];
//    self.twoFeilMuArr = [[NSMutableArray alloc]init];
//
    
            NSString *userID = [HWLocallyStoredData getLoginUserID];
            NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
             NSString *sign = [NSString stringWithFormat:@"%@%@",tStr,@"fsd213ewdsadqwe2121213edsad"];
             NSString *signMD5 = [WMUtil md5HexDigest:sign];
             NSDictionary *parametes = @{
                                       
                                         @"ios" : @"1",
                                         @"t" :tStr,
                                         @"sign": signMD5,
                                         @"type" :self.typeStr,
                                         @"member_id":[HWLocallyStoredData getCode],
                                         @"language":[HWjianzhiduiObject returnLanguageAcquisition],
                                         
                                         
                                        };
    
    [HWWebUtils do4GetWithParameters:parametes  hiddenparameterStr:HW_index  progress:nil success:^(id response) {
        
        // [SVProgressHUD dismiss];
        [self.mainaTableVie.mj_header endRefreshing];
        [self.mainaTableVie.mj_footer endRefreshing];
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];

        if ([codeStr intValue] == 1) {
            
            self.gameArr = [[NSMutableArray alloc]init];
               
                 //   self.reQiP  = @"1";
               
            self.onefeilMuArr = [[NSMutableArray alloc]init];
            self.twoFeilMuArr = [[NSMutableArray alloc]init];
               
            
            
            self.slidArr = response[@"data"][@"slide"];
            self.tuijianDic  =  response[@"data"][@"tuijian"];
            
        //    self.gameArr = response[@"data"][@"game"];
            NSArray *arr = response[@"data"][@"game"];
            
            
            for (int i = 0; i < arr.count; i++) {
                NSArray *arr1 =    [HWmouxingModel mj_objectArrayWithKeyValuesArray:arr[i]];
                [self.gameArr addObject:arr1];
                
                
                
            }
            
            
            
            NSArray * arr12 = response[@"data"][@"fenlei"];
            NSMutableArray *muArr = [arr12 mutableCopy];
            
            if (self.gameArr > 0 ) {
                
                for (int i = 0; i < self.gameArr.count; i++) {
                    [self.onefeilMuArr addObject:muArr[i]];
                }
                
            }
            
           
            
            for (int i = 0; i < self.gameArr.count; i++) {
                [muArr removeObjectAtIndex:0];
                
           }
                          
            
                                                 
            
            self.twoFeilMuArr = muArr;
            
            // 其它
            
            
    
            [self shuxingshuju];
            [self zhongbangtuijshuaxingshuju];
            [self.mainaTableVie reloadData];
            
            [self shuxingbiaoqingView]; 
            
            
           
        }
        NSLog(@"%@",response);
        
        
    } failure:^(NSString *error) {
        [self.mainaTableVie.mj_header endRefreshing];
        [self.mainaTableVie.mj_footer endRefreshing];
        
        
    }];
    
    
    
}




- (void)shuxingbiaoqingView {
    
    
       CGFloat hengjianjuLiin = (kScreenW-  (45)*6 -20)/7;
       for (int i = 0 ; i < self.twoFeilMuArr.count; i++) {
         
             int row = i/6;
             int line = i%6;
             int shulian = (line*2+2) -1;

           
       
       
         
            // UILabel
             UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(hengjianjuLiin*line+hengjianjuLiin+line*45, row*10+10+20* row+35, 45, 20)];
         //     nameLabel.text = fanlilistArr[i];
          nameLabel.textAlignment = NSTextAlignmentCenter;
           nameLabel.font = [UIFont systemFontOfSize:10];
           nameLabel.textColor = RGB(136, 136, 136);
           nameLabel.backgroundColor = [UIColor clearColor];
           nameLabel.layer.cornerRadius = 10;
           nameLabel.layer.masksToBounds = YES;
           nameLabel.layer.borderWidth = 1;
           nameLabel.layer.borderColor = RGB(136, 136, 136).CGColor;
           nameLabel.tag = i;
           nameLabel.userInteractionEnabled = YES;
    
           NSDictionary *dic =   self.twoFeilMuArr[i];
           
           
           UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(biaqinshuju:)];
           
           [nameLabel addGestureRecognizer:tap];
           
           
           nameLabel.text = [NSString stringWithFormat:@"%@",dic[@"name"]];
           
             [ self.baisede1View addSubview:nameLabel];
             // [self.labelMuArr addObject:nameLabel];
             
         
         }
    
    
    
    
    
    
    
    
    
    
    
}


- (void)biaqinshuju:(UITapGestureRecognizer *)tap {
    UIView *view = tap.view;
    
    int tag1 =  view.tag;
    
     NSDictionary *dic =   self.twoFeilMuArr[tag1];
    NSLog(@" 1111  %@",dic);
    
    HWbiaoqiankongzhiViewController *biaoqian = [[HWbiaoqiankongzhiViewController alloc]init];
    biaoqian.dataDic = dic;
    
    [self.navigationController pushViewController:biaoqian animated:YES];
    
    
    
}








- (void)shuxingshuju {
    
    
    
    
    NSMutableArray *arr = [[NSMutableArray alloc]init];
    
    for (int i = 0 ; i < self.slidArr.count; i++) {
        NSDictionary *dic = self.slidArr[i];
        NSString *iamgeStr = [NSString stringWithFormat:@"%@",dic[@"image"]];
        
        [arr addObject:iamgeStr];

    }
    
     self.cycleScrollView.isTooltiao = YES;
     self.cycleScrollView.slideArr = self.slidArr;
     self.cycleScrollView.imageURLStringsGroup = arr;
    
    
    
    
    
}



// 重磅推荐刷新
- (void)zhongbangtuijshuaxingshuju {
    
    
    
    
    
  //   self.icoiamgeView sd_setImageWithURL:<#(nullable NSURL *)#> placeholderImage:<#(nullable UIImage *)#>
    
    
    self.mingchengLabel.text = [NSString stringWithFormat:@"%@",self.tuijianDic[@"name"]];
    
    NSString  *icon = [NSString stringWithFormat:@"%@",self.tuijianDic[@"icon"]];
     [self.icoiamgeView sd_setImageWithURL:[NSURL URLWithString:icon] placeholderImage:nil];
    NSString  *pointStr = [NSString stringWithFormat:@"%@", self.tuijianDic[@"point"]];
    
     [self.starsBut setTitle:pointStr forState:UIControlStateNormal];
     
     
     
    
     
     
    NSArray *arr = (NSArray *)self.tuijianDic[@"biaoqian"];
     
     
     for (int i = 0; i < arr.count; i++) {
          UILabel *label = [self.cardView   viewWithTag:100+i];
          label.hidden = YES;
          label.text = arr[i];
         
         if (i == 0 ) {
           //  label.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(label.frame.size.width, label.frame.size.height) direction:IHGradientChangeDirectionLevel startColor:RGB(255, 188, 114) endColor:RGB(255, 43, 69)];
             label.backgroundColor= RGB(255, 237, 222);
             label.textColor = RGB(248, 119, 6);
             label.hidden = NO;
             CGSize size1 =  [WMUtil sizeWithFont1:[UIFont systemFontOfSize:10] maxSize:CGSizeMake(1000, 200) string:arr[i]];
            
             label.frame =  CGRectMake(self.icoiamgeView.right+10, self.starsBut.bottom+5, size1.width+10, 14);
             
             
         } else if (i == 1) {
             label.hidden = NO;
              // label.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(label.frame.size.width, label.frame.size.height) direction:IHGradientChangeDirectionLevel startColor:RGB(255, 242, 217) endColor:RGB(227, 200, 148)];
             
              label.backgroundColor= RGB(255, 244, 222);
             label.textColor = RGB(235, 174, 56);
             
             UILabel *label0 = [self.cardView   viewWithTag:100];
             
             CGSize size1 =  [WMUtil sizeWithFont1:[UIFont systemFontOfSize:10] maxSize:CGSizeMake(1000, 200) string:arr[i]];
            
             label.frame =  CGRectMake(10+label0.right, self.starsBut.bottom+5, size1.width+10, 14);
             
             
         } else {
             
             label.hidden = NO;
           //     label.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(label.frame.size.width, label.frame.size.height) direction:IHGradientChangeDirectionLevel startColor:RGB(124, 174, 255) endColor:RGB(34, 94, 255)];
               label.backgroundColor= RGB(255, 236, 236);
              label.textColor = RGB(255, 93, 93);
             
             
             UILabel *label0 = [self.cardView   viewWithTag:100+1];
             
             CGSize size1 =  [WMUtil sizeWithFont1:[UIFont systemFontOfSize:10] maxSize:CGSizeMake(1000, 200) string:arr[i]];
            
             label.frame =  CGRectMake(10+label0.right, self.starsBut.bottom+5, size1.width+10, 14);
         }
         

     }
    
    
    
}



#pragma mark --------------- 轮播图代理

- (void)cycleScrollView:(SDCycleScrollViewCdb *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    
    
//    if (self.ADModelMuArr.count > 0) {
//
//        AdModel *model =   self.ADModelMuArr[index];
//
//
//          HWGameDetailsViewController *gameDetails = [[HWGameDetailsViewController alloc]init];
//          gameDetails.gameId = model.gid;
//          [self.navigationController pushViewController:gameDetails animated:YES];
//        return;
//
//    }
    
    NSLog(@"ioohuhuh");
    
      NSDictionary *dic =   self.slidArr[index];
      HWGameDetailController *gameDetails = [[HWGameDetailController alloc]init];
      gameDetails.gameId = dic[@"gid"];
      [self.navigationController pushViewController:gameDetails animated:YES];
            
    
       NSLog(@"%@",dic);
    
    
    
}




- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    
    
    return  self.gameArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    
    return   [self.gameArr[section] count];
    
   
    
    
    
    
    
    
}

 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    static NSString *cellID = @"cellID";
    
    HWHomezhongyaodeCell  *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"HWHomezhongyaodeCell" owner:nil options:nil].firstObject;
        
    }
    HWmouxingModel  *model = self.gameArr[indexPath.section][indexPath.row];
    cell.tuijianModel = model;
    cell.xiantiaoView.hidden = YES;
          
    
    if (indexPath.row == 0 ) {
        
        cell.newbeijingiamgeView.hidden = NO;
        
        cell.xiantiaoView.hidden = NO;
       //  cell.xiantiaoView.hidden = YES;
        cell.beijingshituView.backgroundColor = [UIColor clearColor];
        [cell.beijingtupianIangeview sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:nil];
        
        cell.jianjutupian.constant = 20;
        cell.topjianju.constant = 46;
        
        cell.nameLabel.textColor = RGB(255, 255, 255);
        
        
        
         
    } else {
        
          cell.newbeijingiamgeView.hidden = YES;
         cell.beijingshituView.backgroundColor = [UIColor whiteColor];
        
         cell.jianjutupian.constant = 0;
          cell.topjianju.constant = 31;
         cell.nameLabel.textColor = RGB(68, 68, 68);
        
    }
    
    
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    
    
    
    return  cell;
    
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    if (indexPath.row == 0 ) {
         
        return 162+36+20;
        
    }
    return  78;
    
    
    
}



- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    
    
    return  10+56;
    
    return  44;
    
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return 20;
    
    
    
}


- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    
    
    UIView  *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
    view.backgroundColor = RGB(247, 247, 247);
    
    
    
    UIView *baiseView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, kScreenW-20, 56)];
    baiseView.backgroundColor = RGB(255, 255, 255);
    
    [view addSubview:baiseView];
    
    
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:baiseView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = baiseView.bounds;
        maskLayer.path = maskPath.CGPath;
        baiseView.layer.mask = maskLayer;
    
    
        UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(12, 24,4,16)];
        
        view1.backgroundColor = RGB(248, 119, 6);
    //    view1.layer.cornerRadius = 10;
    //    view1.layer.masksToBounds = YES;
    //
        [baiseView addSubview:view1];
        
    
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(view1.right+6,20, 200, 26)];
               //     nameLabel.text = fanlilistArr[i];
        //  nameLabel.backgroundColor =  RGB(248, 119, 6);
         nameLabel.backgroundColor = [UIColor clearColor];
          nameLabel.textAlignment = NSTextAlignmentLeft;
          nameLabel.font = [UIFont systemFontOfSize:18];
          nameLabel.textColor = RGB(68, 68, 68);
    
   nameLabel.text = @"平台活动";
 //    nameLabel.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:20];//又粗又斜
     //     nameLabel.layer.cornerRadius = 8;
     //     nameLabel.layer.masksToBounds = YES;
    UIFontDescriptor * fontD = [nameLabel.font.fontDescriptor
    fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold
                    | UIFontDescriptorTraitItalic];
    nameLabel.font = [UIFont fontWithDescriptor:fontD size:0];

          nameLabel.text = @"平台活动";
       [baiseView addSubview:nameLabel];
    
    if (self.onefeilMuArr.count > 0) {
        NSDictionary *dic = self.onefeilMuArr[section];
        NSString *nameStr = [NSString stringWithFormat:@"%@", dic[@"name"]];
        nameLabel.text = nameStr;
        
        HWmouxingModel  *model = self.gameArr[section][0];
        nameLabel.text =  model.type;
        
         if(section == 0) {
            
            nameLabel.text = @"热门";
            
         }
        
        
    }
     

    
    
    return  view;
    
    
    
    
    
}


- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    
    
    
    
    UIView  *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 20)];
    view.backgroundColor =RGB(247, 247, 247);
    
    
    UIView *baiseView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, kScreenW-20, 20)];
      baiseView.backgroundColor = RGB(255, 255, 255);
      
      [view addSubview:baiseView];
      
      
          UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:baiseView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
          CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
          maskLayer.frame = baiseView.bounds;
          maskLayer.path = maskPath.CGPath;
          baiseView.layer.mask = maskLayer;
    
    
    
    
    return  view;
    
    
    
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
     HWmouxingModel  *model = self.gameArr[indexPath.section][indexPath.row];
    
    
    
      HWGameDetailController *game = [[HWGameDetailController alloc]init];
       game.gameId = model.id;
      [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:game animated:YES];
       
    
    
    
}

#pragma mark --------- 一些点击事件

- (void)zhongbangtapGes {
    
    
    NSString *idstr =   self.tuijianDic[@"id"];
    
    HWGameDetailController *gamedetail = [[HWGameDetailController alloc]init];
    gamedetail.gameId = idstr;
    [self.navigationController pushViewController:gamedetail animated:YES];
    
    
    
    
}


 

@end
